<?php

namespace Managers\Widget;

abstract class AbstractWidget
{
    /**
     * @var \Zend_View
     */
    protected $view;

    public function __construct()
    {
        $this->view = new \Zend_View();
        $this->initScriptDirectory();
        $this->init();
    }

    private function initScriptDirectory()
    {
        $dirs = \Zend_Controller_Front::getInstance()->getControllerDirectory();
        $baseDir = dirname($dirs['default']) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'scripts';
        $this->view->setScriptPath($baseDir);
    }

    public function init()
    {

    }

    /**
     * Название файла для вывода.
     * @abstract
     *
     */
    public abstract function getScriptName();


    final public function render()
    {
        return $this->view->render($this->getScriptName());
    }
}
